<?php $this->_extends('../_layouts/default_layout'); ?>
<?php $this->_block('contents'); ?>
<link type="text/css" href="<?=Q::ini('custom_system/base_url')?>css/jq.autocomplete.css" rel="stylesheet" />
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/jq.autocomplete.js"></script>
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/md5.js"></script>
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/jq.form.js"></script>
<script type="text/javascript">
/*required*/
var is_leaf = "<?=Q::ini('custom_flag/online_ebay_listing_categories_leaf/leaf/value')?>";
var is_free = "<?=Q::ini('custom_flag/online_ebay_listing_shipping_free/free/value')?>";
var browse_categories_ajax_url = "<?=url('Online::EbayListing/BrowseCategoriesAjax')?>";
var get_info_by_shop_and_site_ajax_url = "<?=url('Online::EbayListing/GetInfoByShopAndSiteAjax') ?>";
var get_info_by_site_ajax_url = "<?=url('Online::EbayListing/GetInfoBySiteAjax')?>";
var get_info_by_categories_ajax_url = "<?=url('Online::EbayListing/GetInfoByCategoryAjax')?>";
var search_category_ajax_url = "<?=url('Online::EbayListing/SearchCategoryAjax')?>";
var submit_url = "<?=url('Online::EbayListing/CopySave')?>";
var verify_url = "<?=url('Online::EbayListing/VerifyAjax')?>";
var SUCCESS = "<?=SUCCESS?>";

/*custom*/
var currency_symbol = "<?=$currency['symbol']?>";
var currency_code = "<?=$currency['code']?>";
var custom_item_specifics_no = 0;
var variaiont_index = 1;
var shipping_location = <?php echo $shipping_location_json?>;
var domestic_shipping_service_option_html = '<?php echo $shipping_service['domestic_shipping_service_option_html']?>';
var domestic_shipping_index = 1;
var international_shipping_service_option_html = '<?php echo $shipping_service['international_shipping_service_option_html']?>';
var international_shipping_index = 1;
</script>
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/online.ebay.js?20150310"></script>
<script type="text/javascript">
$(function(){
	$("#condition_id").change();
	$(".currency_symbol").text(currency_symbol);
	$(".currency_code").text(currency_code);
});
</script>
<form action="<?=url('Online::EbayListing/CopySave')?>" method="post" id="submit_form">
<a href="<?=url('Online::EbayListing/FolderList')?>" class="folder">Manage Folders</a>
<table class="form_table">
<tr>
	<th>Folder</th>
	<td>
		<select name="folder_id" id="folder">		
			<option value="">请选择</option>
			<?foreach ($folder as $f):?>
			<option value="<?=$f['id']?>"><?=$f['name']?></option>
			<?endforeach;?>
		</select>
	</td>
</tr>
</table>

<hr />

<table class="form_table">
<tr>
	<th>Shop</th>
	<td>
		<select name="shop_id" id="shop">
			<?foreach ($shop as $s):?>
			<option value="<?=$s['id']?>" <?if ($listing['shop_id'] == $s['id']):?>selected="selected"<?endif;?>><?=$s['name']?></option>
			<?endforeach;?>
		</select>
	</td>
</tr>
<tr>
	<th>Market</th>
	<td>
		<select name="site" id="site">
			<?foreach (Q::ini('custom_flag/online_ebay_listing_site') as $s):?>
			<option value="<?=$s['value']?>" <?if ($listing['site'] == $s['value']):?>selected="selected"<?endif;?>><?=$s['name']?> - <?=$s['value']?></option>
			<?endforeach;?>
		</select>
	</td>
</tr>
</table>

<hr />

<table class="form_table">
<tr>
	<th>Primary Category</th>
	<td>
		<input type="text" name="primary_category" value="<?=$listing['primary_category']?>" size="7" readonly="readonly" id="primary_category" />
		<a href="#select_ebay_category_box" class="browse-ebay-category-btn" id="browse_ebay_primary_category_btn"><input type="button" value="Browse" class="button" /></a>
		<span><?=$listing['primary_category_name']?></span><input type="hidden" name="primary_category_name" value="<?=$listing['primary_category_name']?>" />
	</td>
</tr>
<tr>
	<th>Second Category</th>
	<td>
		<input type="text" name="second_category" value="<?=$listing['second_category']?>" size="7" readonly="readonly" class="input-mini" />
		<a href="#select_ebay_category_box" class="browse-ebay-category-btn" id="browse_ebay_second_category_btn"><input type="button" value="Browse" class="button" /></a>
		<span><?=$listing['second_category_name']?></span><input type="hidden" name="second_category_name" value="<?=$listing['second_category_name']?>" />
	</td>
</tr>
<tr>
	<th><span class="store-category-loading"></span>Store Category</th>
	<td>
		<select name="store_category" class="store-category-select">
			<option value="">--none--</option>
			<?foreach ($store_categories as $sc):?>
			<option value="<?=$sc['value']?>" <?if ($sc['value'] == $listing['store_category']):?>selected="selected"<?endif;?>><?=$sc['name']?></option>
			<?endforeach;?>
		</select>
	</td>
</tr>
<tr>
	<th><span class="store-category-loading"></span>Store Category 2</th>
	<td>
		<select name="store_category2" class="store-category-select">
			<option value="">--none--</option>
			<?foreach ($store_categories as $sc):?>
			<option value="<?=$sc['value']?>" <?if ($sc['value'] == $listing['store_category2']):?>selected="selected"<?endif;?>><?=$sc['name']?></option>
			<?endforeach;?>
		</select>
	</td>
</tr>
<tr>
	<th>Title</th>
	<td><input type="text" name="title" value="<?=htmlspecialchars($listing['title'])?>" id="title" size="100" /><span style="color: red;"></span></td>
</tr>
<tr>
	<th><span class="condition-loading"></span>Condition</th>
	<td>
		<input type="hidden" name="condition_name" value="<?=$listing['condition_name']?>" />
		<select name="condition_id" id="condition_id">
			<option value="">--none--</option>
			<?foreach ($features['condition'] as $fc):?>
			<option value="<?=$fc['id']?>" <?if ($fc['display_name'] == $listing['condition_name']):?>selected="selected"<?endif;?>><?=$fc['display_name']?></option>
			<?endforeach;?>
		</select>
	</td>
</tr>
<tr>
	<th>Condition Description</th>
	<td><textarea style="width: 600px;" name="condition_description" id="condition_description" readonly="readonly"><?=$listing['condition_description']?></textarea></td>
</tr>
</table>

<hr />
<table class="form_table">
<tbody>
	<tr>
		<th width="120">Custom Label / SKU</th>
		<td><input type="text" name="listing_sku" value="<?=($listing_type == 'Chinese' || $listing_type == 'FixedPriceItem') ? $item['sku'] : ''?>" /></td>
	</tr>
	<tr>
		<th><span class="listing-type-loading"></span>Listing Type</th>
		<td>
			<label><input type="radio" name="listing_type" value="Chinese" <?if ($listing_type == 'Chinese'):?>checked="checked"<?endif;?> id="Chinese_radio" />Standard Auction</label>
			<label><input type="radio" name="listing_type" value="FixedPriceItem" <?if ($listing_type == 'FixedPriceItem'):?>checked="checked"<?endif;?> id="FixedPriceItem_radio" />Standard Fixed Price</label>
			<label id="MultiSKU_label" <?if ( ! $features['variation_enabled']):?>style="display: none;"<?endif;?>><input type="radio" name="listing_type" value="MultiSKU" <?if ($listing_type == 'MultiSKU'):?>checked="checked"<?endif;?> id="MultiSKU_radio" />Multi SKU Variations Fixed Price</label>
		</td>
	</tr>
</tbody>
<tbody id="Chinese_tbody" class="listing-type-body" <?if ($listing_type != 'Chinese'):?>style="display: none;"<?endif;?>>
	<tr>
		<th>Quantity</th>
		<td><input type="text" name="Chinese_quantity" value="1" size="6" readonly="readonly" /></td>
	</tr>
	<tr>
		<th><span class="price-loading"></span>Starting Price</th>
		<td>
			<span class="currency_symbol"></span>
			<input type="text" name="Chinese_start_price" value="<?=($listing_type == 'Chinese') ? $item['start_price'] : ''?>" size="7">
			<span class="currency_code"></span>
		</td>
	</tr>
	<tr>
		<th><span class="price-loading"></span>Buy It Now Price</th>
		<td>
			<span class="currency_symbol"></span>
			<input type="text" name="Chinese_buy_it_now_price" value="<?=($listing_type == 'Chinese') ? $item['buy_it_now_price'] : ''?>" size="7">
			<span class="currency_code"></span>
		</td>
	</tr>
	<tr>
		<th>Duration</th>
		<td>
			<?foreach (Q::ini('custom_flag/online_ebay_listing_duration/standard_auction') as $k => $d):?>
			<label><input type="radio" name="Chinese_duration" value="<?=$d?>" <?if (($listing_type == 'Chinese' && $d == $listing['listing_duration']) || ($listing_type != 'Chinese' && $k == 0)):?>checked="checked"<?endif;?> /><?=$d?></label>
			<?endforeach;?>
		</td>
	</tr>
</tbody>
<tbody id="FixedPriceItem_tbody" class="listing-type-body" <?if ($listing_type != 'FixedPriceItem'):?>style="display: none;"<?endif;?>>
	<tr>
		<th>Quantity</th>
		<td><input type="text" name="FixedPriceItem_quantity" value="<?=($listing_type == 'FixedPriceItem') ? $item['quantity'] : ''?>" size="6" /></td>
	</tr>
	<tr>
		<th><span class="price-loading"></span>Fixed Price</th>
		<td>
			<span class="currency_symbol"></span>
			<input type="text" name="FixedPriceItem_start_price" value="<?=($listing_type == 'FixedPriceItem') ? $item['start_price'] : ''?>" size="7">
			<span class="currency_code"></span>
		</td>
	</tr>
	<tr>
		<th>Duration</th>
		<td>
			<?foreach (Q::ini('custom_flag/online_ebay_listing_duration/standard_fixed_price') as $k => $d):?>
			<label><input type="radio" name="FixedPriceItem_duration" value="<?=$d?>" <?php if (($listing_type == 'FixedPriceItem' && $d == $listing['listing_duration']) || ($listing_type != 'FixedPriceItem' && $k == 0)):?>checked="checked"<?endif;?> /><?=$d?></label>
			<?endforeach;?>
		</td>
	</tr>
</tbody>
<tbody id="MultiSKU_tbody" class="listing-type-body" <?if ($listing_type != 'MultiSKU'):?>style="display: none;"<?endif;?>>
	<tr>
		<th>Duration</th>
		<td>
			<?foreach (Q::ini('custom_flag/online_ebay_listing_duration/multi_sku_variations_fixed_price') as $k => $d):?>
			<label><input type="radio" name="MultiSKU_duration" value="<?=$d?>" <?php if (($listing_type == 'MultiSKU' && $d == $listing['listing_duration']) || ($listing_type != 'MultiSKU' && $k == 0)):?>checked="checked"<?endif;?> /><?=$d?></label>
			<?endforeach;?>
		</td>
	</tr>
	<tr>
		<th style="vertical-align: text-top;">Variations</th>
		<td>
			<div id="MultiSKU_variation_specifics">
				<?foreach ($specifics as $k => $s):?>
				<?if ($s['variation']):?>
				<label><input type="checkbox" value="variation_specifics_entry_<?=$k?>" title="<?=$s['name']?>" <?if (isset($variation_specifics['default_variation_specifics']) && array_key_exists($s['name'], $variation_specifics['default_variation_specifics'])):?>checked="checked"<?endif;?> class="variation-specifics-check" /><?=$s['name']?></label>
				<?endif;?>
				<?endforeach;?>
			</div>
			<div id="MultiSKU_variation_specifics_content" style="display: none;">
				<?foreach ($specifics as $k => $s):?>
				<?if ($s['variation']):?>
				<span id="variation_specifics_entry_<?=$k?>">
					<?if ($s['recommendation']):?>
					<select style="width: 100px;margin-left: -16px;" onchange="$(this).next().val($(this).val());">
						<option></option>
						<?foreach ($s['recommendation'] as $sr):?>
						<option value="<?=$sr?>"><?=$sr?></option>
						<?endforeach;?>
					</select>
					<input type="text" style="margin-left: -103px;width: 80px;" <?if ($s['mode'] == 'SelectionOnly'):?>readonly="readonly"<?endif;?> />
					<?else:?>
					<input type="text" style="width: 80px;" />
					<?endif;?>
				</span>
				<?endif;?>
				<?endforeach;?>
			</div>
			<table class="list_table" id="MultiSKU_variation_content">
			<thead>
				<tr>
					<th><span class="MultiSKU-variation-specifics-text">Sub SKU</span></th>
					<th><span class="MultiSKU-variation-specifics-text">Quantity</span></th>
					<th><span class="MultiSKU-variation-specifics-text">Price</span></th>
					<?if (isset($variation_specifics)):?>
					<?foreach ($variation_specifics['default_variation_specifics'] as $dvs):?>
					<th><span class="MultiSKU-variation-specifics-text"><?=$dvs?></span><a href="javascript:;" class="MultiSKU-variation-specifics-del-btn">Del</a></th>
					<?endforeach;?>
					<?foreach ($variation_specifics['custom_variation_specifics'] as $cvs):?>
					<th><span class="MultiSKU-variation-specifics-text"><?echo $cvs?></span><a href="javascript:;" class="MultiSKU-variation-specifics-del-btn">Del</a></th>
					<?endforeach;?>
					<?endif;?>
					<th><a href="javascript:;" id="MultiSKU_variation_specifics_add_btn">Add Specific</a><input type="text" size="10" id="MultiSKU_variation_specifics_add_text" style="display: none;" /></th>
				</tr>
			</thead>
			<tbody>
				<?if ($listing_type == 'MultiSKU'):?>
				<?foreach ($item as $k => $i):?>
				<tr>
					<td><input type="text" name="variation[<?=$i['id']?>][Sub SKU]" value="<?=$i['sku']?>" size="10" /></td>
					<td><input type="text" name="variation[<?=$i['id']?>][Quantity]" value="<?=$i['quantity']?>" size="6" /></td>
					<td>
						<span class="currency_symbol"></span>
						<input type="text" name="variation[<?=$i['id']?>][Price]" value="<?=$i['start_price']?>" size="7">
						<span class="currency_code"></span>
					</td>
					<?if (isset($variation_specifics)):?>
					<?foreach ($variation_specifics['default_variation_specifics'] as $dvs):?>
					<td width="100">
						<?if ($variation_specifics['default_variation_specifics_detail'][$dvs]['recommendation']):?>
							<select style="width: 100px;margin-left: -16px;" onchange="$(this).next().val($(this).val());">
								<option></option>
								<?foreach ($variation_specifics['default_variation_specifics_detail'][$dvs]['recommendation'] as $r):?>
								<option value="<?=$r?>"><?=$r?></option>
								<?endforeach;?>
							</select>
							<input type="text" name="variation[<?=$i['id']?>][specifics][<?=$dvs?>]" value="<?=$i['variation_specifics'][$dvs]?>" style="margin-left: -103px;width: 80px;" <?if ($variation_specifics['default_variation_specifics_detail'][$dvs]['mode'] == 'SelectionOnly'):?>readonly="readonly"<?endif;?> />
						<?else:?>
							<input type="text" name="variation[<?=$i['id']?>][specifics][<?=$dvs?>]" value="<?=$i['variation_specifics'][$dvs]?>" style="width: 80px;" />
						<?endif;?>
					</td>
					<?endforeach;?>
					<?foreach ($variation_specifics['custom_variation_specifics'] as $cvs):?>
					<td><input type="text" name="variation[<?=$i['id']?>][specifics][<?=$cvs?>]" value="<?=$i['variation_specifics'][$cvs]?>" style="width: 80px;" /></td>
					<?endforeach;?>
					<?endif;?>
					<td>
						<?if ($k != 0):?><a href="javascript:;" onclick="$(this).parent().parent().remove();">Del</a><?endif;?>
						<input type="hidden" class="variation-index" value="<?=$i['id']?>" />
					</td>
				</tr>
				<?endforeach;?>
				<?else:?>
				<tr>
					<td><input type="text" name="variation[add0][Sub SKU]" size="10" /></td>
					<td><input type="text" name="variation[add0][Quantity]" size="6" /></td>
					<td>
						<span class="currency_symbol"></span>
						<input type="text" name="variation[add0][Price]" size="7">
						<span class="currency_code"></span>
					</td>
					<td><input type="hidden" class="variation-index" value="add0" /></td>
				</tr>
				<?endif;?>
			</tbody>
			</table>
			<a href="javascript:;" id="add_variation_btn">+ Add Variation</a>
		</td>
	</tr>
</tbody>
<tbody>
	<tr>
		<th style="vertical-align: text-top;"><span class="item-specifics-loading"></span>Item Specifics</th>
		<td>
			<div id="default_item_specifics">
				<?foreach ($specifics as $k => $s):?>
				<label><input type="checkbox" name="item_specifics[<?=$s['name']?>][checked]" value="1" <?if (array_key_exists($s['name'], $item_specifics['default_item_specifics'])):?>checked="checked"<?endif;?> onclick="if($(this).is(':checked')){$('#item_specifics_entry_<?=$k?>').show();}else{$('#item_specifics_entry_<?=$k?>').hide();}" /><?=$s['name']?></label>
				<?endforeach;?>
			</div>
			<div id="default_item_specifics_content">
				<?foreach ($specifics as $k => $s):?>
				<p id="item_specifics_entry_<?=$k?>" <?if ( ! array_key_exists($s['name'], $item_specifics['default_item_specifics'])):?>style="display: none;"<?endif;?>>
					<span><?=$s['name']?></span><br />
					<?if ($s['recommendation']):?>
					<select style="width: 220px;" onchange="$(this).next().val($(this).val());">
						<option></option>
						<?foreach ($s['recommendation'] as $sr):?>
						<option value="<?=$sr?>"><?=$sr?></option>
						<?endforeach;?>
					</select>
					<input type="text" name="item_specifics[<?=$s['name']?>][value]" value="<?=(array_key_exists($s['name'], $item_specifics['default_item_specifics'])) ? htmlspecialchars($item_specifics['default_item_specifics'][$s['name']]['value']) : ''?>" style="margin-left: -224px; width: 200px;" <?if ($s['mode'] == 'SelectionOnly'):?>readonly="readonly"<?endif;?> />
					<?else:?>
					<input type="text" name="item_specifics[<?=$s['name']?>][value]" value="<?=(array_key_exists($s['name'], $item_specifics['default_item_specifics'])) ? htmlspecialchars($item_specifics['default_item_specifics'][$s['name']]['value']) : ''?>" style="width: 200px;" />
					<?endif;?>
				</p>
				<?endforeach;?>
			</div>
			<div id="custom_item_specifics_content">
				<?foreach ($item_specifics['custom_item_specifics'] as $cis):?>
				<p>
					Name: <input type="text" name="custom_item_specifics[<?=$cis['id']?>][name]" value="<?=$cis['name']?>" />
					Value: <input type="text" name="custom_item_specifics[<?=$cis['id']?>][value]" value="<?=htmlspecialchars($cis['value'])?>" />
					<a href="javascript:;" class="del-custom-item-specifics-btn">Del</a>
				</p>
				<?endforeach;?>
			</div>
			<a href="javascript:;" id="add_custom_item_specifics_btn">+ Add Custom Specifics</a>
		</td>
	</tr>
</tbody>
</table>

<hr />
<table class="form_table">
<tr>
	<th style="vertical-align: text-top;">Image</th>
	<td>
		<table class="list_table">
		<tbody>
			<tr>
				<th width="110">Pictures</th>
				<td align="left">
					<textarea wrap="off" name="picture_urls" style="width: 700px;height: 150px;overflow:scroll;resize: none;" placeholder="Multiple URLs; one URL per Line"><?foreach ($pictures['listing'] as $pl):?><?=$pl['picture_url'] . "\n";?><?endforeach;?></textarea>
				</td>
			</tr>
		</tbody>
		<tbody id="MultiSKU_variation_pictures_tbody" <?if ($listing_type != 'MultiSKU'):?>style="display: none;"<?endif;?>>
			<tr>
				<th>Variation Pictures</th>
				<td align="left">
					<select id="MultiSKU_variation_pictures_specifics_refresh_select" name="MultiSKU_variation_pictures_specifics">
						<option value="">--none--</option>
						<?if ($listing_type == 'MultiSKU'):?>
						<?if (isset($variation_specifics)):?>
						<?foreach ($variation_specifics['default_variation_specifics'] as $dvs):?>
						<option value="<?=$dvs?>" <?if (isset($pictures['variation']) && $pictures['variation'] && $pictures['variation'][0]['specific_name'] == $dvs):?>selected="selected"<?endif;?>><?=$dvs?></option>
						<?endforeach;?>
						<?foreach ($variation_specifics['custom_variation_specifics'] as $cvs):?>
						<option value="<?=$cvs?>" <?if (isset($pictures['variation']) && $pictures['variation'] && $pictures['variation'][0]['specific_name'] == $cvs):?>selected="selected"<?endif;?>><?=$cvs?></option>
						<?php endforeach;?>
						<?php endif;?>
						<?php endif;?>
					</select>
					<a href="javascript:;" id="MultiSKU_variation_pictures_specifics_refresh_btn">Refresh</a>
				</td>
			</tr>
		</tbody>
		<tbody id="MultiSKU_variation_pictures_content" <?if ( ! $pictures['variation']):?>style="display: none;"<?endif;?>>
			<?if ($listing_type == 'MultiSKU'):?>
			<?foreach ($pictures['variation'] as $pv):?>
			<tr id="<?=md5('variation_pictures_' . $pv['specific_name'] . '_' . $pv['specific_value'])?>">
				<td><strong><?=$pv['specific_value']?></strong></td>
				<td align="left"><input type="text" name="variation_picture[<?=$pv['specific_value']?>][url]" value="<?=$pv['picture_url']?>" size="100" /></td>
			</tr>
			<?php endforeach;?>
			<?php endif;?>
		</tbody>
		</table>
	</td>
</tr>
</table>

<hr />
<table class="form_table">
<tr>
	<th style="vertical-align: text-top;">Description<br /><a href="javascript:;" id="preview_btn">Preview</a></th>
	<td width="1000"><textarea name="description" id="description" style="width: 900px;" rows="20"><?=$listing['description']?></textarea></td>
</tr>
<tr>
	<th>Hit Counter</th>
	<td>
		<select name="counter">
		<?foreach (Q::ini('custom_flag/online_ebay_listing_counter') as $c):?>
		<option value="<?=$c?>" <?if ($c == $listing['counter']):?>selected="selected"<?endif;?>><?=$c?></option>
		<?endforeach;?>
		</select>
	</td>
</tr>
</table>

<hr />
<table class="form_table">
<tr>
	<th><span class="shipping-loading"></span>Dispatch Time</th>
	<td>
		<select name="dispatch_time" id="dispatch_time_select">
			<option value="">--none--</option>
			<?foreach ($dispatch as $d):?>
			<option value="<?=$d['value']?>" <?if ($d['value'] == $listing['dispatch_time']):?>selected="selected"<?endif;?>><?=$d['name']?></option>
			<?endforeach;?>
		</select>
		<label><input type="checkbox" name="get_it_fast" value="<?=Q::ini('custom_flag/online_ebay_listing_get_it_fast/fast/value')?>" <?if ($listing['get_it_fast'] == Q::ini('custom_flag/online_ebay_listing_get_it_fast/fast/value')):?>checked="checked"<?endif;?> />Get-It-Fast</label> 
	</td>
</tr>
<tr>
	<th style="vertical-align: text-top;">
		<span class="shipping-loading"></span>Domestic Shipping<br />
		<a id="add_domestic_shipping_service_btn" href="javascript:;">+ Add Shipping Services</a>
	</th>
	<td>
		<table class="list_table">
			<tbody id="domestic_shipping_service_content">
				<?foreach ($listing_shipping['domestic'] as $k => $lsm):?>
				<tr>
					<th <?if ($k == 0):?>width="70"<?endif;?>>Service<?if ($k != 0):?> <a href="javascript:;" class="shipping-service-del-btn">Del</a><?endif;?></th>
					<td align="left">
						<select name="domestic_shipping[<?=$lsm['id']?>][service]">
							<option value="">--none--</option>
							<?foreach ($shipping_service['domestic'] as $c => $ssd):?>
							<optgroup label="<?=$c?>">
								<?foreach ($ssd as $s):?>
								<option value="<?=$s['value']?>" <?if ($s['value'] == $lsm['service']):?>selected="selected"<?endif;?>><?=$s['name']?></option>
								<?endforeach;?>
							</optgroup>
							<?endforeach;?>
						</select>
						Cost: <span class="currency_symbol"></span><input type="text" name="domestic_shipping[<?=$lsm['id']?>][cost]" value="<?=$lsm['cost']?>" <?if ($lsm['free'] == Q::ini('custom_flag/online_ebay_listing_shipping_free/free/value')):?>disabled="disabled"<?endif;?> size="7"><span class="currency_code"></span>
						Additional Cost: <span class="currency_symbol"></span><input type="text" name="domestic_shipping[<?=$lsm['id']?>][additional_cost]" value="<?=$lsm['additional_cost']?>" <?if ($lsm['free'] == Q::ini('custom_flag/online_ebay_listing_shipping_free/free/value')):?>disabled="disabled"<?endif;?> size="7" ><span class="currency_code"></span>
						<label><input type="checkbox" name="domestic_shipping[<?=$lsm['id']?>][free]" value="<?=Q::ini('custom_flag/online_ebay_listing_shipping_free/free/value')?>" <?if ($lsm['free'] == Q::ini('custom_flag/online_ebay_listing_shipping_free/free/value')):?>checked="checked"<?endif;?> class="shipping-free-checkbox" />Free</label>
					</td>
				</tr>
				<?endforeach;?>
			</tbody>
		</table>
	</td>
</tr>
<tr>
	<th style="vertical-align: text-top;">
		<span class="shipping-loading"></span>International Shipping<br />
		<a id="add_international_shipping_service_btn" href="javascript:;">+ Add Shipping Services</a>
	</th>
	<td>
		<table class="list_table">
			<tbody id="international_shipping_service_content">
				<?foreach ($listing_shipping['international'] as $k => $lsi):?>
				<tr>
					<th <?if ($k == 0):?>width="70"<?endif;?>>Service <a href="javascript:;" class="shipping-service-del-btn">Del</a></th>
					<td align="left">
						<select name="international_shipping[<?=$lsi['id']?>][service]">
							<option value="">--none--</option>
							<?foreach ($shipping_service['international'] as $c => $ssi):?>
							<optgroup label="<?=$c?>">
								<?foreach ($ssi as $s):?>
								<option value="<?=$s['value']?>" <?if ($s['value'] == $lsi['service']):?>selected="selected"<?endif;?>><?=$s['name']?></option>
								<?endforeach;?>
							</optgroup>
							<?endforeach;?>
						</select>
						Cost: <span class="currency_symbol"></span><input type="text" name="international_shipping[<?=$lsi['id']?>][cost]" value="<?=$lsi['cost']?>" <?if ($lsi['free'] == Q::ini('custom_flag/online_ebay_listing_shipping_free/free/value')):?>disabled="disabled"<?endif;?> size="7"><span class="currency_code"></span>
						Additional Cost: <span class="currency_symbol"></span><input type="text" name="international_shipping[<?=$lsi['id']?>][additional_cost]" value="<?=$lsi['additional_cost']?>" <?if ($lsi['free'] == Q::ini('custom_flag/online_ebay_listing_shipping_free/free/value')):?>disabled="disabled"<?endif;?> size="7"><span class="currency_code"></span>
						<label><input type="checkbox" name="international_shipping[<?=$lsi['id']?>][free]" value="<?=Q::ini('custom_flag/online_ebay_listing_shipping_free/free/value')?>" <?if ($lsi['free'] == Q::ini('custom_flag/online_ebay_listing_shipping_free/free/value')):?>checked="checked"<?endif;?> class="shipping-free-checkbox" />Free</label><hr style="margin: 4px 0;" />
						Location: <select name="international_shipping[<?=$lsi['id']?>][location]" title="<?=$lsi['id']?>" class="shipping-service-location-select">
							<option value="Worldwide" <?if ($lsi['shipping_location'] == 'Worldwide'):?>selected="selected"<?endif;?>>Worldwide</option>
							<option value="Custom" <?if ($lsi['shipping_location'] != 'Worldwide'):?>selected="selected"<?endif;?>>Custom</option>
						</select><br />
						<div class="shipping-service-location-content">
							<?if ($lsi['shipping_location'] != 'Worldwide'):?>
							<?$tmp_location = explode(',', $lsi['shipping_location']);?>
							<?foreach ($shipping_location as $sl):?>
							<label style="float: left;"><input type="checkbox" name="international_shipping[<?=$lsi['id']?>][location_custom][]" value="<?=$sl['value']?>" <?if (in_array($sl['value'], $tmp_location)):?>checked="checked"<?endif;?> /><?=$sl['name']?></label>
							<?endforeach;?>
							<?endif;?>
						</div>
					</td>
				</tr>
				<?endforeach;?>
			</tbody>
		</table>
	</td>
</tr>
</table>
<hr />
<table class="form_table">
<tr>
	<th>AutoPay</th>
	<td><label><input type="checkbox" name="auto_pay" value="<?=Q::ini('custom_flag/online_ebay_listing_auto_pay/auto/value')?>" <?if ($listing['auto_pay'] == Q::ini('custom_flag/online_ebay_listing_auto_pay/auto/value')):?>checked="checked"<?endif;?> />AutoPay</label></td>
</tr>
<tr>
	<th>Item Location</th>
	<td>
		Country: <select name="country">
			<?foreach ($country as $c):?>
			<option value="<?=$c['code']?>" <?if ($c['code'] == $listing['country']):?>selected="selected"<?endif;?>><?=$c['en_name']?></option>
			<?endforeach;?>
		</select>
		Zip/Postal code: <input type="text" name="postal_code" value="<?=$listing['postal_code']?>" />
		Location: <input type="text" name="location" value="<?=$listing['location']?>" />
	</td>
</tr>
<tr>
	<th><span class="return-policy"></span>Return Policy</th>
	<td>
		<table class="list_table">
			<tbody>
				<tr>
					<th width="200">Accepted</th>
					<td align="left" id="return_policy_accepted_content">
						<?foreach ($return_policy['return_accepted'] as $ra):?>
						<label><input type="radio" name="return_policy" value="<?=$ra['value']?>" <?if ($ra['value'] == $listing['return_policy']):?>checked="checked"<?endif;?> class="return-policy-accepted-radio" /><?=$ra['name']?></label>
						<?endforeach;?>
					</td>
				</tr>
			</tbody>
			<tbody id="return_policy_content" <?if ($listing['return_policy'] != 'ReturnsAccepted'):?>style="display: none;"<?endif;?>>
				<?if (isset($return_policy['restocking_fee'])):?>
				<tr>
					<th>Restocking Fee Value</th>
					<td align="left">
						<select name="return_option_restocking">
							<?foreach ($return_policy['restocking_fee'] as $rf):?>
							<option value="<?=$rf['value']?>" <?if ($rf['value'] == $listing['return_option_restocking']):?>selected="selected"<?endif;?>><?=$rf['name']?></option>
							<?endforeach;?>
						</select>
					</td>
				</tr>
				<?endif;?>
				<?if (isset($return_policy['return_within'])):?>
				<tr>
					<th>Return Within</th>
					<td align="left">
						<select name="return_option_within">
							<?foreach ($return_policy['return_within'] as $rw):?>
							<option value="<?=$rw['value']?>" <?if ($rw['value'] == $listing['return_option_within']):?>selected="selected"<?endif;?>><?=$rw['name']?></option>
							<?endforeach;?>
						</select>
					</td>
				</tr>
				<?endif;?>
				<?if (isset($return_policy['refund'])):?>
				<tr>
					<th>Refund</th>
					<td align="left">
						<select name="return_option_refund">
							<?foreach ($return_policy['refund'] as $r):?>
							<option value="<?=$r['value']?>" <?if ($r['value'] == $listing['return_option_refund']):?>selected="selected"<?endif;?>><?=$r['name']?></option>
							<?endforeach;?>
						</select>
					</td>
				</tr>
				<?endif;?>
				<?if (isset($return_policy['shipping_cost_paid_by'])):?>
				<tr>
					<th>Return Shipping Paid By</th>
					<td align="left">
						<select name="return_option_paid_by">
							<?foreach ($return_policy['shipping_cost_paid_by'] as $scpb):?>
							<option value="<?=$scpb['value']?>" <? if ($scpb['value'] == $listing['return_option_paid_by']):?>selected="selected"<?endif;?>><?=$scpb['name']?></option>
							<?endforeach;?>
						</select>
					</td>
				</tr>
				<?endif;?>
				<?if ($return_policy['description']):?>
				<tr>
					<th>Additional Return Policy Details</th>
					<td align="left"><textarea name="return_option_description" style="width: 500px;height: 100px;resize: none;"><?=$listing['return_option_description']?></textarea><br />(5000 Chars Max. No HTML)</td>
				</tr>
				<?endif;?>
			</tbody>
		</table>
	</td>
</tr>
</table>
<hr />
<table class="form_table">
<tr>
	<th><input type="checkbox" id="set_schedule" name="set_schedule"/>Schedule Time</th>
	<td>
		<div id="schedule_div">
			<input name="date" id="date" value="" class="datepicker" /> /&nbsp;
			<select id="hour" name="hour">
				<?for ($i = 0; $i < 24; $i++):?>
				<option value="<?=str_pad($i, 2, 0, STR_PAD_LEFT)?>"><?=str_pad($i, 2, 0, STR_PAD_LEFT)?></option>
				<?endfor;?>
			</select> 时 :
			<select id="minute" name="minute">
				<?for ($j = 0; $j < 60; $j++):?>
				<option value="<?=str_pad($j, 2, 0, STR_PAD_LEFT)?>"><?=str_pad($j, 2, 0, STR_PAD_LEFT)?></option>
				<?endfor;?>
			</select> 分  =>
			<label>Timezone</label>
			<select id="timezone" name="timezone">
				<?foreach (Q::ini('custom_flag/timezone') as $z):?>
				<option value="<?=$z['value']?>" ><?=$z['name']?></option>
				<?endforeach;?>
			</select>
			<span id="show_time"></span>
		</div>
	</td>
</tr>
<tr>
	<th><input type="checkbox" id="schedule_repeat" name="schedule_repeat" />Repeat Duration</th>
	<td>
		<input id="schedule_repeat_step" name="schedule_repeat_step" value="" />Days
	</td>
</tr>
</table>
</form>
<div align="center" style="width: 70%; margin-top: 8px;">
<input type="button" value="提交" class="button" id="submit_btn" />
<input type="button" value="检测错误&费用" class="button" style="width: 100px;" id="verify_btn" />
<img src="<?=Q::ini('custom_system/base_url')?>img/loading.gif" style="display: none" />
</div>

<!-- ebay categories select box -->
<div id="select_ebay_category_box" style="display: none;">
<h1 style="background: #eee; font-size: 16px; padding: 10px 0px 10px 10px;">Select a Category...</h1>
<table width="100%" style="text-align: center;">
<tr>
	<td height="40px" colspan="3" align="left">
		搜索产品分类&nbsp;&nbsp;<input type="text" id="ebay_category_search_input" value="" size="100" />
	</td>
</tr>
<tr>
	<td colspan="3" align="left">选择产品分类</td>
</tr>
<tr>
	<td width="33%">
		<input type="hidden" value="" class="categories-select" id="categories_0">
		<span>Primary Category</span>
		<select size="8" style="width: 100%" class="categories-select" id="categories_1"></select>
	</td>
	<td width="33%">
		<span>Sub Category #1</span>
		<select size="8" style="width: 100%" class="categories-select" id="categories_2"></select>
	</td>
	<td width="33%">
		<span>Sub Category #2</span>
		<select size="8" style="width: 100%" class="categories-select" id="categories_3"></select>
	</td>
</tr>
<tr>
	<td width="33%">
		<span>Sub Category #3</span>
		<select size="8" style="width: 100%" class="categories-select" id="categories_4"></select>
	</td>
	<td width="33%">
		<span>Sub Category #4</span>
		<select size="8" style="width: 100%" class="categories-select" id="categories_5"></select>
	</td>
	<td width="33%">
		<span>Sub Category #5</span>
		<select size="8" style="width: 100%" class="categories-select" id="categories_6"></select>
	</td>
</tr>
</table>
<p><strong>Selected Category: </strong><span id="categories_select_id"></span></p>
<p><strong>Selected Category Name: </strong><span id="categories_select_name"></span></p>
<div align="right">
<input type="button" value="Cancel" class="button" id="select_ebay_category_cancel_btn" />
<input type="button" value="Select" class="button" id="select_ebay_category_select_btn" />
<input type="hidden" id="ebay_categories_callback_btn" value="" />
</div>
</div>

<div id="dialog_verify_info" title="上架检测错误信息和上架费用提示">
<table class="list_table" width="100%">
	<tr>
		<th width="60">结果</th>
		<td id="verify_ack" align="left"></td>
	</tr>
	<tr>
		<th>错误信息</th>
		<td id="verify_errors" align="left"></td>
	</tr>
	<tr>
		<th>上架费用</th>
		<td id="verify_fee" align="left"></td>
	</tr>
</table>
</div>
<?php $this->_endblock();?>